﻿using Lamex.Base;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Lamex.mIE.Calculate
{
    public class LGC_UNT_P31_SAW
    {
        //F P31后工序为P33
        //  附加开木条工时=6
        //Else
        //  附加开木条工时=0
        //End If
        //LGC_TIM_P31_SAW=(W+H)*0.05+附加开木条工时
        public static double LGC_UNT_P31_SAW_VALUE(string Part_No)
        {
            double result_Val = 0;
            double W = 0, H = 0;
            double Attach = 0;
            DataTable dtSize = BaseBuildSql.GetDataTableBySql(" select WIDTH,HEIGHT FROM IE_Part_SizeParmList where PART_NO='" + Part_No + "'");
            DataTable dtRouting = BaseBuildSql.GetDataTableBySql(" select GROUP_CODE FROM IE_Part_Routing where PART_NO='" + Part_No + "'");
            if (dtSize.Rows.Count > 0)
            {
                if (dtSize.Rows[0]["WIDTH"].ToString().Length > 0)
                    W = double.Parse(dtSize.Rows[0]["WIDTH"].ToString());
                if (dtSize.Rows[0]["HEIGHT"].ToString().Length > 0)
                    H = double.Parse(dtSize.Rows[0]["HEIGHT"].ToString());
                if (dtRouting.Rows.Count > 0)
                {
                    DataTable dtCombination = BaseBuildSql.GetDataTableBySql(" select ROUTING_CODE FROM IE_Routing_Combination where GROUP_CODE='" + dtRouting.Rows[0]["GROUP_CODE"] + "'");
                    if (dtCombination.Rows.Count > 0)
                    {
                        string[] list = dtCombination.Rows[0]["ROUTING_CODE"].ToString().Split('_');
                        if (list.Contains("P31_P33"))
                            Attach = 6;
                    }
                }
            }
            result_Val = (W + H) * 0.05 + Attach;
            return result_Val;
        }
    }
}
